package com.example.rbac.aop;


import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

import java.lang.reflect.Method;

public class TestInterceptor implements MethodInterceptor{
    @Override
    public Object invoke(MethodInvocation methodInvocation) throws Throwable {
        Method method = methodInvocation.getMethod();
        Test anntation = getAnntation(method);
        return methodInvocation.proceed();
    }

    public Test getAnntation(Method method){
        if (method.isAnnotationPresent(Test.class)){
            return method.getAnnotation(Test.class);
        }
        return null;
    }
}
